package com.itqf.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;

/**
 * @Description:  转发  重定向
 * @Company: 千锋互联
 * @Author: 李丽婷
 * @Date: 2021/1/20
 * @Time: 上午11:41
 */
@Controller
public class MyJumpController {


    @RequestMapping("/test1")
    public  String test1(HttpServletRequest request){
        System.out.println("转发页面 test1");
        request.setAttribute("name","request作用域中的值");
        return "forward:/jsp/success.jsp";
    }

    @RequestMapping("/test2")
    public  String test2(HttpServletRequest request){
        System.out.println("转发到另一个请求 test2");
        request.setAttribute("name","request作用域中的值");
        return "forward:/hello";
    }

    @RequestMapping("/hello")
    public  String hello(HttpServletRequest request){
        System.out.println("hello"+request.getAttribute("name"));
        return "/jsp/success.jsp";
    }


    @RequestMapping("/test3")
    public  String test3(HttpServletRequest request){
        System.out.println("重定向到页面 test3");
        request.setAttribute("name","request作用域中的值");
        return "redirect:/jsp/success.jsp";
    }

    @RequestMapping("/test4")
    public  String test4(HttpServletRequest request){
        System.out.println("重定向到另一个请求 test4");
        request.setAttribute("name","request作用域中的值");
        return "redirect:/hello";
    }


}
